#ifndef BOOK_MANAGE
#define BOOK_MANAGE
#include "../book/book.h"
#include <vector>
#include <string>
#include <fstream>

struct SearchOutput
{
    float confidance;
    book* ptr;
};

enum BookManageErrCode
{
    SystemOK,
    RepeatName,
    RepeatID,
    NameNotMatch,
    BookIsToBeDel,
    NotAllowBorrow,
    BookIsDel
};

class bookmanager
{
public:
    //构造函数
    bookmanager();

    //功能函数
    BookManageErrCode addbook(book _book);
    BookManageErrCode delbook(std::string name);
    uint32_t findbookbyname(std::string _name);
    book* findbookbyID(uint32_t ID);
    bool checkrepeat(book _book);
    BookManageErrCode operator<<(book& _book);
    BookManageErrCode borrowBook(std::string name, book& _book);
    BookManageErrCode borrowBook(book* ptr);
    BookManageErrCode returnBook(book& ptr);
    BookManageErrCode returnBook(book* ptr);

    std::vector<SearchOutput> search(std::string name);

    void loadDataFromLocalDataBase(std::string path);
private:
    std::vector<book> books;
    
};

namespace bookmanage
{
bool compare(SearchOutput&,SearchOutput&);
bool findConfidence(std::string,book,float&);
}

#endif